package com.butterfly.domain.dao;

import com.butterfly.domain.entity.PointConfiguration;
import com.butterfly.domain.entity.PointParameter;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import javax.inject.Named;

@Named
public class PointConfigurationDAOImpl extends AbstractDaoHibernate<PointConfiguration> implements PointConfigurationDAO {
    @Override
    protected Class<PointConfiguration> getEntityClass() {
        return PointConfiguration.class;
    }


    @Override
    public PointConfiguration getPointConfig(String value) {
        Criteria criteria = getSession().createCriteria(PointConfiguration.class);
        criteria.add(Restrictions.eq("parameter", value));
        if (criteria.list().size() > 0) {
            return (PointConfiguration) criteria.list().get(0);
        }
        return null;
    }
}
